package com.lyc.demo;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.ribbon.RibbonClient;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import java.util.Map;

@SpringBootApplication
@EnableEurekaClient
@RestController
//@Controller
public class ServiceHiApplication {

    public static void main(String[] args) {
        SpringApplication.run(ServiceHiApplication.class, args);
    }

    @Value("${server.port}")
    String port;

    @RequestMapping("/hi")
    public String home(@RequestParam(value = "name", defaultValue = "forezp") String name, ModelAndView modelAndView) {
//        return "hi " + name + " ,i am from port:" + port;
        modelAndView.addObject("ok", 1111111111 + name);
        return "show" + name;
    }


    @RequestMapping(value = "/hi2")
    public String home2(@RequestBody Map<String, String> params) {
        return "show" + params.get("name");
    }

}